﻿<Grid x:Class="DemoApp.Demos.Airspace.WPFCubes"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Width="300" Height="300">
    <Grid Name="first">
        <Grid.Triggers>
            <EventTrigger RoutedEvent="Grid.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Duration="0:0:5"
                               From="0" To="360"
                               RepeatBehavior="Forever"
                               Storyboard.TargetProperty="Children[0].Children[0].(ModelVisual3D.Transform).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)"
                               Storyboard.TargetName="cube" />
                        <DoubleAnimation Duration="0:0:5"
                               From="0" To="360"
                               RepeatBehavior="Forever"
                               Storyboard.TargetProperty="Children[0].Children[1].(ModelVisual3D.Transform).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)"
                               Storyboard.TargetName="cube" />
                        <DoubleAnimation Duration="0:0:5"
                               From="0" To="360"
                               RepeatBehavior="Forever"
                               Storyboard.TargetProperty="Children[0].Children[2].(ModelVisual3D.Transform).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)"
                               Storyboard.TargetName="cube" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>
        <Ellipse Stroke="Blue" StrokeThickness="5"/>
        <Viewport3D x:Name="cube">
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0,0,5" LookDirection="0,0,-1" UpDirection="0,1,0"/>
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <PointLight Position="-10,7,50" Color="White"/>
                </ModelVisual3D.Content>
                <ModelVisual3D.Children>
                    <ModelVisual3D>
                        <ModelVisual3D.Transform>
                            <RotateTransform3D>
                                <RotateTransform3D.Rotation>
                                    <AxisAngleRotation3D Axis="0,1,0" Angle="0"/>
                                </RotateTransform3D.Rotation>
                            </RotateTransform3D>
                        </ModelVisual3D.Transform>
                        <ModelVisual3D.Children>
                            <ModelVisual3D>
                                <ModelVisual3D.Transform>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D Axis="1,0,1" Angle="45"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </ModelVisual3D.Transform>
                                <ModelVisual3D.Content>
                                    <GeometryModel3D>
                                        <GeometryModel3D.Geometry>
                                            <MeshGeometry3D Positions="1,1,1 1,1,-1 -1,1,-1 -1,1,1 1,-1,1 1,-1,-1 -1,-1,-1 -1,-1,1" TriangleIndices="0,1,2 2,3,0 0,4,1 4,5,1 1,5,2 5,6,2 2,6,3 6,7,3 3,7,0 7,4,0 4,6,5 4,7,6"/>
                                        </GeometryModel3D.Geometry>
                                        <GeometryModel3D.Material>
                                            <MaterialGroup>
                                                <DiffuseMaterial Brush="Red"/>
                                                <SpecularMaterial Brush="#444"/>
                                            </MaterialGroup>
                                        </GeometryModel3D.Material>
                                    </GeometryModel3D>
                                </ModelVisual3D.Content>
                            </ModelVisual3D>
                        </ModelVisual3D.Children>
                    </ModelVisual3D>
                    <ModelVisual3D>
                        <ModelVisual3D.Transform>
                            <RotateTransform3D>
                                <RotateTransform3D.Rotation>
                                    <AxisAngleRotation3D Axis="0,0,1" Angle="0"/>
                                </RotateTransform3D.Rotation>
                            </RotateTransform3D>
                        </ModelVisual3D.Transform>
                        <ModelVisual3D.Children>
                            <ModelVisual3D>
                                <ModelVisual3D.Transform>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D Axis="1,0,1" Angle="35"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </ModelVisual3D.Transform>
                                <ModelVisual3D.Content>
                                    <GeometryModel3D>
                                        <GeometryModel3D.Geometry>
                                            <MeshGeometry3D Positions="1,1,1 1,1,-1 -1,1,-1 -1,1,1 1,-1,1 1,-1,-1 -1,-1,-1 -1,-1,1" TriangleIndices="0,1,2 2,3,0 0,4,1 4,5,1 1,5,2 5,6,2 2,6,3 6,7,3 3,7,0 7,4,0 4,6,5 4,7,6"/>
                                        </GeometryModel3D.Geometry>
                                        <GeometryModel3D.Material>
                                            <MaterialGroup>
                                                <DiffuseMaterial Brush="Blue"/>
                                                <SpecularMaterial Brush="#444"/>
                                            </MaterialGroup>
                                        </GeometryModel3D.Material>
                                    </GeometryModel3D>
                                </ModelVisual3D.Content>
                            </ModelVisual3D>
                        </ModelVisual3D.Children>
                    </ModelVisual3D>
                    <ModelVisual3D>
                        <ModelVisual3D.Transform>
                            <RotateTransform3D>
                                <RotateTransform3D.Rotation>
                                    <AxisAngleRotation3D Axis="1,0,0" Angle="0"/>
                                </RotateTransform3D.Rotation>
                            </RotateTransform3D>
                        </ModelVisual3D.Transform>
                        <ModelVisual3D.Children>
                            <ModelVisual3D>
                                <ModelVisual3D.Transform>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D Axis="1,0,1" Angle="25"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </ModelVisual3D.Transform>
                                <ModelVisual3D.Content>
                                    <GeometryModel3D>
                                        <GeometryModel3D.Geometry>
                                            <MeshGeometry3D Positions="1,1,1 1,1,-1 -1,1,-1 -1,1,1 1,-1,1 1,-1,-1 -1,-1,-1 -1,-1,1" TriangleIndices="0,1,2 2,3,0 0,4,1 4,5,1 1,5,2 5,6,2 2,6,3 6,7,3 3,7,0 7,4,0 4,6,5 4,7,6"/>
                                        </GeometryModel3D.Geometry>
                                        <GeometryModel3D.Material>
                                            <MaterialGroup>
                                                <DiffuseMaterial Brush="#0F0"/>
                                                <SpecularMaterial Brush="#444"/>
                                            </MaterialGroup>
                                        </GeometryModel3D.Material>
                                    </GeometryModel3D>
                                </ModelVisual3D.Content>
                            </ModelVisual3D>
                        </ModelVisual3D.Children>
                    </ModelVisual3D>
                </ModelVisual3D.Children>
            </ModelVisual3D>
        </Viewport3D>
    </Grid>
</Grid>
